function setTimeCount(timeRemain)
{
    $('.daysRemain').each(function(){
        $(this).html(timeRemain[0]);
	});
	$('.hoursRemain').each(function(){
        $(this).html(timeRemain[1]);
	});
	$('.minutesRemain').each(function(){
        $(this).html(timeRemain[2]);
	});
	$('.secondsRemain').each(function(){
        $(this).html(timeRemain[3]);
	});
}

function countdown(container, timeLeft)
{
   var saveTime = timeLeft;
	if (timeLeft > 0)
	{
		days = Math.floor(timeLeft / (60 * 60 * 24));
		timeLeft %= (60 * 60 * 24);
		hours = Math.floor(timeLeft / (60 * 60));
		timeLeft %= (60 * 60);
		minutes = Math.floor(timeLeft / 60);
		seconds = timeLeft % 60;

		var flag = false;
		if (days > 0)
		{
            days = ((days<10)?('0'+days):days);
			flag = true;
		}
		if (flag || (hours > 0))
		{
            hours = ((hours<10)?('0'+hours):hours);
			flag = true;
		}
		if (flag || (minutes > 0))
		{
            minutes = ((minutes<10)?('0'+minutes):minutes);
			flag = true;
		}
		if (flag || (seconds > 0))
		{
            seconds = ((seconds<10)?('0'+seconds):seconds);
		}
        timeRemain = [days, hours, minutes, seconds];
		setTimeCount(timeRemain);
		setTimeout('countdown("' + container + '",' + (saveTime-1) + ');', 1000);

	 }
	 else
	 {
		$('#'+container).hide();
	 }

}